<%@page import="com.hhit.collaborative_learning.utils.Utils"%>
<%@page import="com.hhit.collaborative_learning.dao.impl.PublicDaoImplMySql"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String type=request.getParameter("type");
	String currentPage=request.getParameter("currentPage");
	String orderby=request.getParameter("orderby");
	orderby=orderby==null?"dataTime":orderby;
	PublicDaoImplMySql dao=new PublicDaoImplMySql();
	request.setAttribute("dataPage", dao.getDataPage(type, currentPage, orderby));
	request.setAttribute("orderby", orderby);
%>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="<%=basePath%>css/download.css" rel="stylesheet"
	type="text/css" />

<!-- test toolbar nav-->
<link rel="stylesheet" href="<%=basePath%>css/index.css">
<script src="<%=basePath%>js/jquery-1.11.1.min.js"
	type="text/javascript"></script>
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>css/News-nav.css">
<!-- toolbar nav -->

<script language='JavaScript' type='text/javascript'
	src='<%=basePath%>js/jquery.form.js'></script>
<script language='JavaScript' type='text/javascript'
	src='<%=basePath%>js/jquery.cookie.js'></script>

</head>
<body>
	<div class="news-nav">
		<div class="container clearfix">
			<div class="nav-bar">
				<a href="<%=basePath %>download/download.jsp" target="_top" class="current">首页</a> 
				<a href="<%=basePath %>download/mydata.jsp" onclick="checkLogin()">我的资源</a>
				<a href="<%=basePath%>download/search.jsp?type=3" target="_blank">搜索</a>
			</div>
		</div>
	</div>
	<div id="wrap">
		<div class="way_nav">
			<a href="<%=basePath %>download/download.jsp" target="_top">首页</a><em>&gt;</em><%=Utils.getDataRelativeName(type) %>
		</div>
		<div class="content">
			<!-- left area -->
			<div class="left">
				<!-- Tags -->
				<div class="tag_box">
					<h2>
						<a href="category.jsp?type=<%=type%>"><%=Utils.getDataRelativeName(type) %></a><span>共<dfn>${dataPage.count}</dfn>个资源
						</span>
					</h2>
				</div>
				<!-- left classfiy list -->
				<div class="bor_box_1 mb_1">
					<!-- tab -->
					<div class="tab_1">
						<ul>
							<li <c:if test="${orderby eq 'dataTime'}">class="select"</c:if>><a href="category.jsp?type=<%=type%>">按时间排序</a></li>
							<li <c:if test="${orderby eq 'dataDownloadNum'}">class="select"</c:if>><a href="category.jsp?type=<%=type%>&orderby=dataDownloadNum">按下载量排序</a></li>
						</ul>
					</div>
					<!-- list -->
					<c:forEach items="${dataPage.list}" var="data">
						<dl class="list_1">
							<dt>
								<a href="<%=basePath %>download/downloadpage.jsp?dataId=${data.dataId}">${data.dataName}</a><span
									class="marks">${data.dataPoint}</span>
							</dt>
							<dd class="tag">
								标签： 
								<c:forEach items="${data.dataTag}" var="tag">
									<a href="javascript:void(0);">${tag}</a>
								</c:forEach>
							</dd>
							<dd>${data.dataDesc}</dd>
							<dd class="res_intro">
								<div class="fr">
									<span class="uploader">上传者：<a href="<%=basePath %>download/mydata.jsp?userId=${data.dataUId}"
										class="user_name">${data.dataUserName}</a></span><span class="time_upload">上传时间：${data.dataTime}</span>
								</div>
								<div class="fl">
									<span class="time_download">下载次数：${data.dataDownloadNum}</span> <span class="classfiy">资源类型：${data.dataCategory }</span>
	
								</div>
							</dd>
						</dl>
					</c:forEach>

					<!-- page nav -->
					<div class="page_nav">
								<span>共${requestScope.dataPage.totalPage}页</span>
								<c:if test="${requestScope.dataPage.currentPage>1}">
									<a href="category.jsp?type=<%=type%>&currentPage=1&orderby=<%=orderby%>">首页</a>
									<a
										href="category.jsp?type=<%=type%>&currentPage=${requestScope.dataPage.currentPage-1}&orderby=<%=orderby%>">上一页</a>
								</c:if>
								<c:if test="${requestScope.dataPage.pageDiffer>0}">
									<a
										href="category.jsp?type=<%=type%>&currentPage=${requestScope.dataPage.pageDiffer*5-4}&orderby=<%=orderby%>">...</a>
								</c:if>

								<c:if
									test="${requestScope.dataPage.pageDiffer*5+1<=requestScope.dataPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.dataPage.currentPage==requestScope.dataPage.pageDiffer*5+1 }">
											<strong>${requestScope.dataPage.pageDiffer*5+1}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="category.jsp?type=<%=type%>&currentPage=${requestScope.dataPage.pageDiffer*5+1}&orderby=<%=orderby%>">${requestScope.dataPage.pageDiffer*5+1}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.dataPage.pageDiffer*5+2<=requestScope.dataPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.dataPage.currentPage==requestScope.dataPage.pageDiffer*5+2 }">
											<strong>${requestScope.dataPage.pageDiffer*5+2}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="category.jsp?type=<%=type%>&currentPage=${requestScope.dataPage.pageDiffer*5+2}&orderby=<%=orderby%>">${requestScope.dataPage.pageDiffer*5+2}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.dataPage.pageDiffer*5+3<=requestScope.dataPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.dataPage.currentPage==requestScope.dataPage.pageDiffer*5+3 }">
											<strong>${requestScope.dataPage.pageDiffer*5+3}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="category.jsp?type=<%=type%>&currentPage=${requestScope.dataPage.pageDiffer*5+3}&orderby=<%=orderby%>">${requestScope.dataPage.pageDiffer*5+3}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.dataPage.pageDiffer*5+4<=requestScope.dataPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.dataPage.currentPage==requestScope.dataPage.pageDiffer*5+4 }">
											<strong>${requestScope.dataPage.pageDiffer*5+4}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="category.jsp?type=<%=type%>&currentPage=${requestScope.dataPage.pageDiffer*5+4}&orderby=<%=orderby%>">${requestScope.dataPage.pageDiffer*5+4}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.dataPage.pageDiffer*5+5<=requestScope.dataPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.dataPage.currentPage==requestScope.dataPage.pageDiffer*5+5 }">
											<strong>${requestScope.dataPage.pageDiffer*5+5}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="category.jsp?type=<%=type%>&currentPage=${requestScope.dataPage.pageDiffer*5+5}&orderby=<%=orderby%>">${requestScope.dataPage.pageDiffer*5+5}</a>
										</c:otherwise>
									</c:choose>
								</c:if>
								<c:if
									test="${requestScope.dataPage.totalPage>5 && requestScope.dataPage.pageDiffer<requestScope.dataPage.totalPage/5-1}">
									<a
										href="category.jsp?type=<%=type%>&currentPage=${requestScope.dataPage.pageDiffer*5+6}&orderby=<%=orderby%>">...</a>
								</c:if>
								<c:if
									test="${requestScope.dataPage.currentPage<requestScope.dataPage.totalPage}">
									<a
										href="category.jsp?type=<%=type%>&currentPage=${requestScope.dataPage.currentPage+1}&orderby=<%=orderby%>">下一页</a>
									<a
										href="category.jsp?type=<%=type%>&currentPage=${requestScope.dataPage.totalPage}&orderby=<%=orderby%>">尾页</a>
								</c:if>
						</div>

				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
	function checkLogin(){
		if($.cookie("userId")){
			return true;
		}
		if(confirm("需要登录，是否登录?")){
			var links=top.location.href.substring(7).split("/");
			top.location.href="<%=basePath%>login.jsp?link="+encodeURIComponent(links[2]+"/"+links[3]);
			return false;
		}
		return false;
	}
	(function(){
	$(function(){
		var back_top_value =Math.ceil(document.documentElement.clientHeight *0.65);
		var float_ask_img="<div data-mod='popu_64' class='tracking-ad' chg-blk='0' ><a id='com-ask-float-block' target='_blank' title='文件上传' style='top:"+(back_top_value-41)+"px'></a></div>";
		$("body").append(float_ask_img);
		$("#com-ask-float-block").click(function(){
			if(checkLogin()){
				$(this).attr("href","<%=basePath%>download/upload.jsp");
			}
		});
	});
	})();
	</script>

	<!-- ask 全局悬浮按钮  -->
	<link href="<%=basePath %>css/ask_float_block.css"
		rel="stylesheet" type="text/css" />
</body>
</html>
